package de.distMLP.train;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hama.bsp.BSPPeer;
import org.apache.hama.bsp.sync.SyncException;

import de.distMLP.messages.HamaMessage;
import de.mlp_distributed.mlp.math.mahout.Matrix;

public class MLP_RPROP extends MLP_MiniBatchGD {

	@Override
	protected void updateWeightMatrix(final Matrix[] weightChangesSum) {
		this.mlp.updateiWeightPlus(weightChangesSum, this.error, this.lastError);
	}

	@Override
	public void setup(final BSPPeer<LongWritable, Text, NullWritable, Text, HamaMessage> peer) throws IOException, SyncException,
			InterruptedException {
		super.setup(peer);
		/**
		 * need to compute error on each iteration for RRPROP to work properly.
		 */
		this.calculateErrorOnEachIteration = true;
		this.batchSize = 0;
		this.batchLearning = true;
	}
}
